package com.project.database;

import com.project.model.ColumnData;
import com.project.util.Util;
import lombok.Data;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Data
public class TableData {

    private String tableName;
    private Map<String, ColumnData> tableFiled;
    private List<String> tableFiledList;
    private String primaryKey;

    public List<String> getTableFiledList() {
        return tableFiledList;
    }

    public void addColumn(String column) {
        this.tableFiledList.add(column);
    }

    public TableData(String tableName) {
        this.tableName = Util.mysqlTableNameToJavaName(tableName);
        this.tableFiled = new HashMap<>();
        this.tableFiledList = new ArrayList<>();
    }

    public ColumnData addColumnData( ColumnData columnData ){
        this.tableFiled.put(columnData.getColumnName(), columnData);
        return tableFiled.get(columnData.getColumnName());
    }

    public void setPrimaryKey(String primaryKey) {
        this.primaryKey = primaryKey;
    }
}
